﻿Public Class frm_buscarProve

    Private Sub rbt_id_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbt_id.CheckedChanged

        txt_nombre.Enabled = False
        txt_idProve.Enabled = True
        txt_idProve.Focus()

    End Sub

    Private Sub rbt_nombre_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbt_nombre.CheckedChanged

        txt_idProve.Enabled = False
        txt_nombre.Enabled = True
        txt_nombre.Focus()
    End Sub

    Private Sub cmd_buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_buscar.Click

        If rbt_id.Checked = True Then
            If IsNumeric(txt_idProve.Text) Then
                frm_proveedor.buscarPorId(txt_idProve.Text)
            Else
                MessageBox.Show("Ingrese un ID válido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                txt_idProve.Text = ""
                txt_idProve.Focus()
            End If
        Else
            frm_proveedor.buscarPorNombre(txt_nombre.Text)
        End If
        Me.Close()
    End Sub

    Private Sub cmd_cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_cancelar.Click
        Me.Close()
    End Sub

    
    Private Sub frm_buscarProve_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txt_idProve.Text = ""
        txt_nombre.Text = ""
        rbt_nombre.Checked = True
    End Sub
End Class